package covertjava.classloader;

/**
* <p>Prints a hierarchy of class loaders that was used to load this class</p>
* <p>Copyright: Copyright (c) 2004 Sams Publishing</p>
* @author Alex Kalinovsky
* @version 1.0
*/
public class PrintClassLoaders {

    public static void main(String[] args) {
        System.out.println("System class loader = " + ClassLoader.getSystemClassLoader());
        System.out.println("Thread context class loader = " + Thread.currentThread().getContextClassLoader());

        System.out.println("Class loader hierarchy for this class:");
        String padding = "";
        ClassLoader cl = PrintClassLoaders.class.getClassLoader();
        while (cl != null) {
            System.out.println(padding + cl);
            cl = cl.getParent();
            padding += "    ";
        }
        System.out.println(padding + "null (bootstrap class loader)");
    }
}

